package com.bjpowernode.web.controller;

import com.bjpowernode.api.vo.RechargeInfo;
import com.bjpowernode.web.views.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: panDeng_Zhu
 * @time: 2022/11/19 12:56
 */

@Api(tags = "充值接口")
@RestController
public class RechargeController extends BaseController {

    @ApiOperation(value = "用户充值", notes = "用户充值金额")
    @PostMapping("/v1/recharge/info")
    public ResultView userRecharge(@RequestHeader("userId") Integer userId,
                                   @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
                                   @RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize) {
        ResultView<RechargeInfo> result = ResultView.FAIL();
        if (userId != null) {
            List<RechargeInfo> rechargeInfoList = rechargeService.queryUserRechargeByUserId(userId, pageNo, pageSize);
            result=ResultView.SUCCESS();
            result.setList(rechargeInfoList);
        }
        return result;
    }
}
